Skip to content

Add ability to run tests with jQuery Migrate #1774

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

Add ability to run tests with jQuery Migrate #1774

wants to merge 1 commit into from

Conversation

eirslett
Copy link
Contributor

@eirslett eirslett commented Dec 4, 2016

This is inspired by #1773 which fixes some JQMIGRATE warnings; but it only fixed a couple ones I stumbled over. In this PR, I added the ability to run all unit tests with jquery-migrate loaded, so that all warnings show up in the console. This will make it easier to systematically fix all migrate warnings, and possibly catch any new ones that are introduced.

Example: Open the browser and run tests: http://localhost:7777/tests/unit/all.html?jquery=3.1.0&migrate=3.0.0

You can then see warnings that appear in the console.

if ( version === "git" ) {
url = "http://code.jquery.com/jquery-migrate-" + version;
} else {
url = "../../../external/jquery-migrate-" + ( version || "1.12.4" ) + "/jquery-migrate";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no jquery-migrate-1.12.4. But we also don't need a default version here since the migrate plugin isn't loaded by default and you have to explicitly specify the version to include.

This also needs to be registered with QUnit so that a UI element is generated. See tests/lib/qunit.js and search for QUnit.config.urlConfig. Since there's a 1:1 mapping between the jQuery version and the jQuery Migrate version, I'd prefer if the migrate config was a boolean. This function should look at the jQuery version to determine the jQuery Migrate version to load.

jQuery 1.x and 2.x -> jQuery Migrate 1.4.1
jQuery 3.x -> jQuery Migrate 3.0.0
jQuery Git -> jQuery Migrate Git

Copy link
Contributor Author

@eirslett eirslett Jan 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated with your suggestion to resolve jquery-migrate version depending on jquery version. Added QUnit config for it. ?migrate is now a boolean.

"jquery-3.1.1/LICENSE.txt": "jquery-3.1.1/LICENSE.txt"
"jquery-3.1.1/LICENSE.txt": "jquery-3.1.1/LICENSE.txt",

"jquery-migrate-3.0.0/jquery-migrate.js": "jquery-migrate-3.0.0/jquery-migrate.js"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll want 1.4.1 as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

"jquery-3.1.1/LICENSE.txt": "jquery-3.1.1/LICENSE.txt"
"jquery-3.1.1/LICENSE.txt": "jquery-3.1.1/LICENSE.txt",

"jquery-migrate-3.0.0/jquery-migrate.js": "jquery-migrate-3.0.0/jquery-migrate.js"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing the license file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@eirslett
Copy link
Contributor Author

eirslett commented Jan 30, 2017

I updated the PR now.
I had to install jquery-migrate from the npmjs tgz files, because the default bower repositories were referring to some third party repository, which neither had a license file or version 1.4.1 published.
Trying to install jquery/jquery-migrate#1.4.1 with bower downloaded the individual source files of jquery-migrate, but not the built distribution.
Looks like jquery-migrate is configured to be published to npm primarily.

Update: the code is ready for a new code review now.

Run tests with ?jquery=3.1.1&migrate=true to
get JQMIGRATE warnings in the console.
Copy link
Member

@scottgonzalez scottgonzalez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just two minor things, but I'll fix them when I merge.

url = "http://code.jquery.com/jquery-migrate-git";
} else if ( jqueryVersion[ 0 ] === "3" ) {
url = "../../../external/jquery-migrate-3.0.0/jquery-migrate";
} else {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a condition here for jqueryVersion[ 0 ] === "1" || jqueryVersion[ 0 ] === "2" and then make the else block throw an error so that when jQuery 4 is released, we'll know that we need to check the appropriate jQuery Migrate version.

@@ -68,6 +69,10 @@ function requireTests( dependencies, noBackCompat ) {
dependencies.push( "testswarm" );
}

if ( parseUrl().migrate ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't actually working because parseUrl() doesn't support booleans right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants